﻿using System;

namespace Fractions
{
    class FractionNumber: IFormattable
    {
        int nominator;
        int denominator;

        public int Nominator
        {
            get
            {
                return nominator;
            }
            set
            {
                nominator = value;
            }
        }

        public int Denominator
        {
            get
            {
                return denominator;
            }
            set
            {
                denominator = value;
            }
        }

        public FractionNumber(int nominator, int denominator)
        {
            this.nominator = nominator;
            this.denominator = denominator;
        }

        public string ToString(string format, IFormatProvider formatProvider)
        {
            string result;
            if (format == "N")
            {
                result = string.Format("{0}/{1}", nominator, denominator);
            }
            else if (format == "R")
            {
                result = string.Format("{0:f2}", (double)nominator / denominator);
            }
            else
            {
                result = string.Format("{0:f8}", (double)nominator / denominator);
            }
            return result;
        }
    }
}